{{ define "content"}}
  <div class="container managePost" style="min-height: 300px;">
<!-- 个人介绍 -->
<div class="card text-center" style="width: 18rem;" id="selfDiscribe">
  <img src="/img/nav1.png" class="card-img-top" alt="Fissure in Sandstone"/>
  <div class="card-body">
    <h5 class="card-title">{{ .HomeName }}</h5>
    <p class="card-text">这个人很神秘，什么也没留下</p>
    <!-- 如果浏览的这个人的id等于目前房主的这个id -->
    <!-- 那么就拥有编辑权限。自带一个home函数返回home的id值 -->
    {{ if .CanEdit }}
      <a  class="btn btn-primary edit">编辑博客</a>
      <a  class="btn btn-primary unedit">看看效果</a>
    {{ else }}
      <a href="#!" class="btn btn-primary ">关注</a>
    {{ end }}
  </div>
</div>

<!-- 个人介绍 end -->
    <!-- 帖子 可复用 用循环-->
    {{ if .HasPost }}
      {{ range .Posts}}
    <section class="mb-5 showPost">
      <div class="row">
        <div class="col-lg-6">
          <p class="small text-muted">{{ .CreateTime}}</p>
          <h2 class="fw-bold mb-3">
            <a href="/post/{{ .Pid }}" class="text-reset">{{ .Title }}</a>
          </h2>
          <p class="text-muted">
            {{ .Content}}
          </p>
          <p class="small text-muted">
            By <a href="/home/{{ .User_id }}" class="text-reset">{{ .Author }}</a>
            
          </p>
        </div>
        <div class="col-lg-6">
          <figure class="figure d-block mb-0">
            <div class="bg-image hover-overlay hover-zoom rounded-6 mb-2">
              <img
                class="w-100 rounded-6"
                src="https://mdbootstrap.com/img/new/blog/33.jpg"
                style="object-fit: cover; height: 312px"
                alt="Article image"
              />
              <a href="#!">
                <div class="mask"></div>
              </a>
            </div>
            <figcaption class="figure-caption">
              Cluj-Napoca, Romania; Radu Chelariu for Unsplash
            </figcaption>
          </figure>
        </div>
      </div>
    </section>
    <!-- <hr class="divider-horizontal" style="margin-bottom: 3.5rem;"> -->
     <!-- 帖子 end-->
       {{ end }}
     {{ else }}
     <section class="mb-5 managePost" >
        {{ if .CanEdit }}
        <h3>没有留下东西，快去编辑点什么吧</h3>
        {{ else}}
        <h3>这里空空如也</h3>
        {{ end }}
    </section>
    <hr class="divider-horizontal" style="margin-bottom: 3.5rem;">
     {{ end }}
  </div>
  <!-- 个人文章修改部分-->
<div class="container controlPost hidden" >
    <table class="table">
      <thead class="table-light">
        <tr>
          <th scope="col">标题</th>
          <th scope="col">时间</th>
          <th scope="col">编辑</th>
          <th scope="col">删除</th>
        </tr>
      </thead>
      <tbody>
        {{ if .HasPost }}
        {{ range .Posts}}
        <tr>
          <th scope="row">{{ .Title }}</th>
          <td>{{ .CreateTime}}</td>
          <td>
            <a href="/update/{{ .Pid }}" style="color:white">
            <button type="button" class="btn btn-dark px-3 me-2" data-mdb-toggle="modal" >
             编辑
            </button>
            </a>
          </td>
          <td>
            <a href="/delete/{{ .Pid }}" style="color:white">
            <button type="button" class="btn btn-dark px-3 me-2" >
            删除
           </button>
          </a>
          </td>
        </tr>
        {{ end }}
      {{ end }}
      </tbody>
    </table>
    <button type="button" class="btn btn-primary me-3" data-mdb-toggle="modal" data-mdb-target="#AddPost">
      新增
     </button>
  </div>
  <div class="modal fade" id="AddPost" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">新建随笔</h5>
          <button type="button" class="btn-close" data-mdb-dismiss="modal" aria-label="Close"></button>
        </div>
        <div class="modal-body addPost">
    <form action="/addPost/{{ .UserId }}" method="post">
             <div class="form-outline mb-4 ">
              <input type="text" id="Title" class="form-control" name="PostTitle"/>
              <label class="form-label" for="Title">标题</label>
              <div class="invalid-feedback"></div>
              <div class="valid-feedback">验证通过</div>
            </div>
  
            <div class="form-outline mb-4">
              <textarea name="PostContent" id="Content" cols="40" rows="10"></textarea>
              <label class="form-label" for="Content">内容</label>
              <div class="invalid-feedback"></div>
              <div class="valid-feedback">验证通过</div>
            </div>
            <!-- Submit button -->
            <button type="submit" class="btn btn-primary btn-block">新增</button>
          </form>
        </div>
       
      </div>
    </div>
  </div>

  {{ end }}